package com.ceshiren.chnjx.wework.page;

import com.ceshiren.chnjx.wework.page.contact.ContactPage;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

/**
 * @author JJJJ
 * @Title:
 * @date 2021/11/6下午4:25
 * @Description:
 */
public class MainPage extends BasePage {
    private By bottomSelector = By.id("f0d");
    private By contactBtn = By.xpath("//*[@text='通讯录']");
    private By msgBtn = By.xpath("//*[@text='信息']");
    private By backButton = By.id("iwk");
    public MainPage(AppiumDriver driver) {
        super(driver);
    }


    public ContactPage intoContactPage(){
        click(contactBtn);
        return new ContactPage(driver);
    }

    /**
     * 返回到通讯录页面
     */
    public MainPage backToMainPage(){
        try {
            findEle(bottomSelector);
        }catch (Exception e){
            back();
            backToMainPage();
        }
        click(msgBtn);
        return this;
    }

    /**
     * 点击返回按键
     */
    public MainPage back(){
        click(backButton);
        return this;
    }

}
